package com.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;

/**
 * 生成条形码
 */
@RestController
@Slf4j
public class ImageController {

    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("/getBarCode")
    public void getBarCode(String code, HttpServletResponse response) throws Exception{
        BufferedImage image = BarCodeUtil.insertWords(BarCodeUtil.getBarCode(code), code);
        ImageIO.write(image, "jpg", response.getOutputStream());
    }

}